package com.example.demo.service;

import com.example.demo.bean.Good;

import java.math.BigDecimal;

/**
 * @ClassName: Context
 * @Description: 使用上下文维护算法策略
 * @Author: Administrator
 * @Date: Created in 2022/11/19 23:04
 */
public class Context {

    BuyStrategy buyStrategy;

    public Context(BuyStrategy buyStrategy){
        this.buyStrategy = buyStrategy;
    }

    public BigDecimal calculate(Good good, BigDecimal num) throws Exception {
        return buyStrategy.calculate(good,num);
    }

}
